1. Technical Field
The disclosure is related to a data storage method in a distributed system.
2. Related Art
In a distributed system, data accessing is one of the most important tasks to maintain the operation thereof. A position of data accessing is determined according to a formula or mechanism computation of the distributed system so that data may be stored in a node in the distributed system, which is also referred to as a storage node. Any requesting node which has the need to access the data obtains the position for accessing the data by using the same manner so as to update or change the data.
One of the most common architectures of the distributed system is a peer-to-peer (P2P) network architecture, which is considered as the core technology for the network foundation and service. The peer-to-peer session initiation protocol (P2PSIP) working group of the Internet Engineering Task Force (IETF) is proceeding with the development of a protocol standard defining a P2P-based REsource LOcation And Discovery (RELOAD) for standardizing the operations and data storage in the P2P network. However, the RELOAD protocol standard is a P2P signaling protocol to form the overlay network rather than as a database storage protocol. The RELOAD protocol standard features in allowing an application to access data placed in a P2P network through a RELOAD requesting node. Nevertheless, a RELOAD storage node is merely in charge of receiving and responding an access request and incapable of identifying from which application the request is send or whether the data should be locked for a specific application. Hence, the RELOAD may be not able to avoid the problem of race condition.
For instance, FIG. 1 is a schematic diagram illustrating a race condition in a distributed system adopting the RELOAD protocol standard. Referring to FIG. 1, a RELOAD distributed system 100 has a storage node S having a data counter of a “number of views”. There are two requesting nodes A and B in the RELOAD distributed system 100. The requesting nodes A and B read an original data counter “100” of the “number of views” simultaneously or with a slight time difference. The requesting node A updates the data counter of the “number of views” as “101” after reading the “number of views”. Meanwhile, the requesting node B also updates the data counter of the “number of views” as “101” after reading the “number of views”. Namely, the data counter of the “number of views” stored in the storage node S is updated as “101”. However, in fact, after being downloaded by the requesting nodes A and B, the correct data counter of the “number of views” should be updated as “102”. Such error occurs due to the requesting nodes A and B simultaneously writing the data counter of the “number of views” into the storage node S without avoiding the race condition and separately arranging the actions, which results in data error.
Accordingly, how to avoid the race condition in the distributed system has become a subject. Currently, a centralized coordinator (e.g. a central server) for access allocation in the distributed system is developed, where each requesting node in the distributed system is controlled by the centralized coordinator. Another technique is to establish a server-client architecture in the distributed system to avoid the race condition; however, therein, both the requesting nodes and the storage nodes may need to change operational mechanisms thereof. Still another developed technique is to avoid the race condition by notifying or coordinating among each requesting node in the distributed system, and therein, each requesting node should be aware about all other requesting nodes in the network which are also interested in the same storage node, and then, only one requesting node has access right which is determined by negotiation between requesting nodes.